<template>
    <div class="user-center">
      <!-- 用户头像和基本信息 -->
      <div class="user-info">
        <div class="avatar">
          <img src="@/assets/image.jpg" alt="User Avatar" />
        </div>
        <div class="details">
          <h2>{{ userData.nickname }}</h2>
          <p>等级: {{ userData.level }}</p>
          <p>会员有效期: {{ userData.membership }}</p>
        </div>
      </div>
  
      <!-- 用户统计信息 -->
      <div class="user-stats">
        <div class="stat-card">
          <h3>文章</h3>
          <p>{{ userData.articles }}</p>
        </div>
        <div class="stat-card">
          <h3>收藏</h3>
          <p>{{ userData.favorites }}</p>
        </div>
        <div class="stat-card">
          <h3>点赞</h3>
          <p>{{ userData.likes }}</p>
        </div>
      </div>
  
      <!-- 用户详细信息 -->
      <div class="user-details">
        <div class="section">
          <h3>基本信息</h3>
          <div class="data-list">
            <div class="data-item">
              <span>性别:</span>
              <span>{{ userData.gender }}</span>
            </div>
            <div class="data-item">
              <span>年龄:</span>
              <span>{{ userData.age }}</span>
            </div>
            <div class="data-item">
              <span>联系方式:</span>
              <span>{{ userData.contact }}</span>
            </div>
          </div>
        </div>
  
        <div class="section">
          <h3>操作</h3>
          <div class="button-group">
            <button @click="editProfile">编辑个人资料</button>
            <button @click="logout">退出登录</button>
          </div>
        </div>
      </div>
    </div>
  </template>
  
  <script setup lang="ts">
  import { ref } from 'vue';
  
  // 用户数据接口
  interface UserData {
    nickname: string;
    level: string;
    membership: string;
    articles: number;
    favorites: number;
    likes: number;
    gender: string;
    age: number;
    contact: string;
  }
  
  // 假设的用户数据
  const userData: UserData = {
    nickname: '笑麻了',
    level: '高级会员',
    membership: '2224-12-31',
    articles: 120,
    favorites: 85,
    likes: 320,
    gender: '女',
    age: 18,
    contact: '2518419928@qq.com',
  };
  
  // 编辑个人资料函数
  const editProfile = () => {
    alert('编辑个人资料功能暂未实现');
  };
  
  // 退出登录函数
  const logout = () => {
    alert('退出登录功能暂未实现');
  };
  </script>
  
  <style scoped>
  .user-center {
    max-width: 1200px;
    margin: 40px auto;
    padding: 20px;
  }
  
  .user-info {
    display: flex;
    align-items: center;
    gap: 30px;
    margin-bottom: 30px;
  }
  
  .avatar img {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    object-fit: cover;
  }
  
  .user-info .details {
    flex: 1;
  }
  
  .user-stats {
    display: flex;
    justify-content: space-between;
    gap: 30px;
    margin-bottom: 30px;
  }
  
  .stat-card {
    flex: 1;
    background: #fff;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
    text-align: center;
  }
  
  .stat-card h3 {
    font-size: 18px;
    margin-bottom: 10px;
    color: #333;
  }
  
  .stat-card p {
    font-size: 24px;
    font-weight: bold;
    color: #666;
  }
  
  .user-details {
    background: #fff;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
  }
  
  .section {
    margin-bottom: 30px;
  }
  
  .section h3 {
    font-size: 20px;
    margin-bottom: 10px;
    color: #333;
  }
  
  .data-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
  }
  
  .data-item {
    padding: 15px;
    background: #f8f8f8;
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
  }
  
  .button-group {
    display: flex;
    gap: 20px;
  }
  
  button {
    padding: 12px 20px;
    border: none;
    border-radius: 5px;
    font-size: 16px;
    cursor: pointer;
  }
  
  button:first-child {
    background: #409eff;
    color: #fff;
  }
  
  button:first-child:hover {
    background: #66b1ff;
  }
  
  button:last-child {
    background: #dcdcdc;
    color: #333;
  }
  
  button:last-child:hover {
    background: #c5c5c5;
  }
  </style>